﻿package flash.display {
	/**
	 * @author Jānis Radiņš
	 * Flash player 10 flash.display.GraphicsPath class implementation for flash player 9
	 * This is done for sake of forward compability
	 */
	public final class GraphicsPath implements IGraphicsPath, IGraphicsData {
		/**
		 * The Vector of drawing commands as integers representing the path. 
		 * Each command can be one of the values defined by the GraphicsPathCommand class.
		 */
		public var commands:Array = null;
		/**
		 * The Vector of Numbers containing the parameters used with the drawing commands.
		 */
		public var data:Array = null;
		/**
		 * Specifies the winding rule using a value defined in the GraphicsPathWinding class.
		 */
		public var winding:String = null;
		/**
		 * Creates a new GraphicsPath object. 
		 * @param	commands 	(default = null) — A Array of integers representing commands defined by the GraphicsPathCommand class.
		 * @param	data		(default = null) — A Array of Numbers where each pair of numbers is treated as a point (an x, y pair).
		 * @param	winding		(default = "evenOdd") — Specifies the winding rule using a value defined in the GraphicsPathWinding class. 
		 */
		public function GraphicsPath(commands:Array = null, data:Array = null, winding:String = "evenOdd") {
			this.commands = (commands != null ? commands : new Array());
			this.data = (data != null ? data : new Array());
			this.winding = winding;
		}
		/**
		 * Adds a new "curveTo" command to the commands vector and new coordinates to the data vector.
		 * @param	controlX	A number that specifies the horizontal position of the control point relative to the registration point of the parent display object.
		 * @param	controlY	A number that specifies the vertical position of the control point relative to the registration point of the parent display object.
		 * @param	anchorX		A number that specifies the horizontal position of the next anchor point relative to the registration point of the parent display object.
		 * @param	anchorY		A number that specifies the vertical position of the next anchor point relative to the registration point of the parent display object. 
		 */
		public function curveTo(controlX:Number, controlY:Number, anchorX:Number, anchorY:Number):void {
			commands.push(GraphicsPathCommand.CURVE_TO);
			data.push(controlX, controlY, anchorX, anchorY);
		}
		/**
		 * Adds a new "lineTo" command to the commands vector and new coordinates to the data vector.
		 * @param	x	The x coordinate of the destination point for the line.
		 * @param	y	The y coordinate of the destination point for the line.
		 */
		public function lineTo(x:Number, y:Number):void {
			commands.push(GraphicsPathCommand.LINE_TO);
			data.push(x, y);
		}
		/**
		 * Adds a new "moveTo" command to the commands vector and new coordinates to the data vector.
		 * @param	x	The x coordinate of the destination point.
		 * @param	y	The y coordinate of the destination point. 
		 */
		public function moveTo(x:Number, y:Number):void {
			commands.push(GraphicsPathCommand.MOVE_TO);
			data.push(x, y);
		}
		/**
		 * Adds a new "wideLineTo" command to the commands vector and new coordinates to the data vector.
		 * @param	x	The x-coordinate of the destination point for the line.
		 * @param	y	The y-coordinate of the destination point for the line.
		 */
		public function wideLineTo(x:Number, y:Number):void {
			commands.push(GraphicsPathCommand.WIDE_LINE_TO);
			data.push(x, y, x, y);
		}
		/**
		 * Adds a new "wideMoveTo" command to the commands vector and new coordinates to the data vector.
		 * @param	x	The x-coordinate of the destination point.
		 * @param	y	The y-coordinate of the destination point.
		 */
		public function wideMoveTo(x:Number, y:Number):void {
			commands.push(GraphicsPathCommand.WIDE_MOVE_TO);
			data.push(x, y, x, y);
		}
	}
}